package com.coship.vasms.adstorm.common.log;

import org.apache.log4j.Level;

/**
 * 
 * 
 * File Name    : BizLevel.java
 * @Description 	: 自定义业务使用日志级�?
 * @author 903329
 */
public final class BizLevel extends Level {

	static public final int BIZ_INT = Level.WARN_INT -1;

	private static String BIZ_STR = "BIZ";

	public static final BizLevel BIZ = new BizLevel(BIZ_INT, BIZ_STR, 7);

	protected BizLevel(int level, String strLevel, int syslogEquiv) {
		super(level, strLevel, syslogEquiv);
	}

	/**
	 * Convert the String argument to a level. If the conversion fails then this
	 * method returns {@link #BIZ}.
	 */
	public static Level toLevel(String sArg) {
		return (Level) toLevel(sArg, BizLevel.BIZ);
	}

	/**
	 * Convert the String argument to a level. If the conversion fails, return
	 * the level specified by the second argument, i.e. defaultValue.
	 */
	public static Level toLevel(String sArg, Level defaultValue) {
		if (sArg == null) {
			return defaultValue;
		}
		String stringVal = sArg.toUpperCase();
		if (stringVal.equals(BIZ_STR)) {
			return BizLevel.BIZ;
		}
		return Level.toLevel(sArg, (Level) defaultValue);
	}

	/**
	 * Convert an integer passed as argument to a level. If the conversion
	 * fails, then this method returns {@link #DEBUG}.
	 */
	public static Level toLevel(int i) throws IllegalArgumentException {
		if (i == BIZ_INT) {
			return BizLevel.BIZ;
		} else {
			return Level.toLevel(i);
		}
	}
}
